package com.test.runable;

import com.test.pojo.DataEntity;

import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * 数据状态3时候的处理任务，处理完之后走到状态4
 */
public class Task3 extends Task implements Runnable {
    private ConcurrentLinkedQueue<DataEntity> queue;

    public Task3(ConcurrentLinkedQueue<DataEntity> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while (true) {
            DataEntity dataEntity = queue.poll();
            if (dataEntity != null) {
                doSomethingForCertainTime(dataEntity,10);
            } else {
                System.out.println("DataEntity is null, sleep for 1 second!");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
